//
//  DownLoad.h
//  Leisure
//
//  Created by lanou3g on 16/4/12.
//  Copyright © 2016年 wenze. All rights reserved.
//

#import <Foundation/Foundation.h>

typedef void(^FinishLoad)(NSString *filePath,NSString *url);
typedef void(^Downloading)(float progress,long speed);

@protocol DownLoadDelegate <NSObject>

// 通知管理者 当前下载任务结束 管理者接到消息放弃对当前任务对象的持有
- (void)didFinishLoadWithUrl:(NSString *)url;

@end

@interface DownLoad : NSObject

@property (nonatomic,strong)NSString *url;
// 计算出的进度是float类型 * 100 做百分数
@property (nonatomic,assign)float progress;

@property (nonatomic,assign)id<DownLoadDelegate> delegate;
// 下载结束 传出url 和下载文件的实际路径(可与数据库操作结合)
@property (nonatomic,copy)FinishLoad finishLoad;

@property (nonatomic,copy)Downloading downloading;


- (instancetype)initWithUrl:(NSString *)url;

- (void)start;

- (void)pause;
// 使用当前方法传递block参数  必须实现
- (void)didFinishWithFinishLoad:(FinishLoad)finish andDownloading:(Downloading)download;

@end
